﻿CREATE PROCEDURE [dbo].[ASIGNAR_ROL_USUARIO]
@UserName varchar(8),
@RoleName varchar(20)
AS
declare
	@UserId int,
	@RoleId int
begin				


		SELECT  @UserId =  U.UserId
		FROM dbo.UserProfile U  
		where U.UserName = @UserName
		
		SELECT  @RoleId =  R.RoleId
		FROM dbo.webpages_Roles R 
		where R.RoleName = @RoleName 
		
		IF @UserId != 1
		begin
		DELETE FROM dbo.webpages_UsersInRoles WHERE UserId = @UserId
		INSERT INTO dbo.webpages_UsersInRoles VALUES(@UserId,@RoleId)		
		end
end